package com.sxf.mybatis.enhance;


public class BeanUtils {
	/**
	 * 包装类转换为原生类
	 * 
	 * @param wrapperClass
	 * @return
	 */
	public static Class<?> toPrimitiveClass(Class<?> wrapperClass) {
		if (wrapperClass == Integer.class) {
			return Integer.TYPE;
		} else if (wrapperClass == Byte.class) {
			return Byte.TYPE;
		} else if (wrapperClass == Short.class) {
			return Short.TYPE;
		} else if (wrapperClass == Long.class) {
			return Long.TYPE;
		} else if (wrapperClass == Float.class) {
			return Float.TYPE;
		} else if (wrapperClass == Double.class) {
			return Double.TYPE;
		} else if (wrapperClass == Character.class) {
			return Character.TYPE;
		} else if (wrapperClass == Boolean.class) {
			return Boolean.TYPE;
		} else {
			return wrapperClass;
		}
	}
	
	/**
	 * 将8原生类型的类转换为对应的包装的类型。
	 */
	public static Class<?> toWrapperClass(Class<?> primitiveClass) {
		if (primitiveClass == Integer.TYPE)
			return Integer.class;
		if (primitiveClass == Long.TYPE)
			return Long.class;
		if (primitiveClass == Double.TYPE)
			return Double.class;
		if (primitiveClass == Short.TYPE)
			return Short.class;
		if (primitiveClass == Float.TYPE)
			return Float.class;
		if (primitiveClass == Character.TYPE)
			return Character.class;
		if (primitiveClass == Byte.TYPE)
			return Byte.class;
		if (primitiveClass == Boolean.TYPE)
			return Boolean.class;
		return primitiveClass;
	}
}
